package com.example.springboot.controller.requstParams;

import com.example.springboot.entity.User;
import com.example.springboot.pojo.Human;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 自定义类型的参数解析器为 ServletModelAttributeMethodProcessor
 * public boolean supportsParameter(MethodParameter parameter) {
 *         return parameter.hasParameterAnnotation(ModelAttribute.class) ||
 *         this.annotationNotRequired && !BeanUtils.isSimpleProperty(parameter.getParameterType());
 *     }
 *     resolve data时会创建WebDataBinder web参数绑定器，
 * @Author:ChenZhangKun
 * @Date: 2021/6/16 20:51
 */
@RestController
public class OwnDefineParameterController {
    @PostMapping("/user1212")
    public User user(User user) {
        return user;
    }

    /**
     * 测试自己的类型格式化器
     * 关联页面 form.html
     * @param human
     * @return
     */
    @PostMapping("/save/pet")
    public Human save(Human human){
        return human;
    }
}
